/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package org.base;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author mmanto
 */
@Entity
@Table(name = "expediente")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Expediente.findAll", query = "SELECT e FROM Expediente e"),
    @NamedQuery(name = "Expediente.findById", query = "SELECT e FROM Expediente e WHERE e.id = :id"),
//    @NamedQuery(name = "Expediente.findByPartidoId", query = "SELECT e FROM Expediente e WHERE e.partidoId = :partidoId"),
    @NamedQuery(name = "Expediente.findByAlcance", query = "SELECT e FROM Expediente e WHERE e.alcance = :alcance"),
    @NamedQuery(name = "Expediente.findByCuerpo", query = "SELECT e FROM Expediente e WHERE e.cuerpo = :cuerpo"),
    @NamedQuery(name = "Expediente.findByExtracto", query = "SELECT e FROM Expediente e WHERE e.extracto = :extracto"),
    @NamedQuery(name = "Expediente.findByFechaInicio", query = "SELECT e FROM Expediente e WHERE e.fechaInicio = :fechaInicio"),
    @NamedQuery(name = "Expediente.findByTipoExpediente", query = "SELECT e FROM Expediente e WHERE e.tipoExpediente = :tipoExpediente"),
    @NamedQuery(name = "Expediente.findByNumero", query = "SELECT e FROM Expediente e WHERE e.numero = :numero")})
public class Expediente implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
//    @Basic(optional = false)
//    @NotNull
//    @Column(name = "partido_id")
//    private int partidoId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 40)
    @Column(name = "alcance")
    private String alcance;
    @Size(max = 40)
    @Column(name = "cuerpo")
    private String cuerpo;
    @Size(max = 40)
    @Column(name = "extracto")
    private String extracto;
    @Column(name = "fecha_inicio")
    @Temporal(TemporalType.DATE)
    private Date fechaInicio;
    @Column(name = "tipo_expediente")
    private Integer tipoExpediente;
    @Size(max = 20)
    @Column(name = "numero")
    private String numero;
    @JoinColumn(name = "tipo_expediente_id", referencedColumnName = "id")
    @ManyToOne
    private TipoExpediente tipoExpedienteId;
    @JoinColumn(name = "barrio_id", referencedColumnName = "id")
    @ManyToOne
    private Barrio barrioId;
   
//    @Column(name = "partido")
    @JoinColumn(name = "partido_id", referencedColumnName = "id")
    @ManyToOne
    private Partido partido;

    public Partido getPartido() {
        return partido;
    }

    public void setPartido(Partido partido) {
        this.partido = partido;
    }

    public Expediente() {
    }

    public Expediente(Integer id) {
        this.id = id;
    }

//    public Expediente(Integer id, int partidoId, String alcance) {
//        this.id = id;
//        this.partidoId = partidoId;
//        this.alcance = alcance;
//    }

    public Expediente(Integer id, Partido partido, String alcance) {
        this.id = id;
        this.partido = partido;
        this.alcance = alcance;
    }
    
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

//    public int getPartidoId() {
//        return partidoId;
//    }
//
//    public void setPartidoId(int partidoId) {
//        this.partidoId = partidoId;
//    }

    public String getAlcance() {
        return alcance;
    }

    public void setAlcance(String alcance) {
        this.alcance = alcance;
    }

    public String getCuerpo() {
        return cuerpo;
    }

    public void setCuerpo(String cuerpo) {
        this.cuerpo = cuerpo;
    }

    public String getExtracto() {
        return extracto;
    }

    public void setExtracto(String extracto) {
        this.extracto = extracto;
    }

    public Date getFechaInicio() {
        return fechaInicio;
    }

    public void setFechaInicio(Date fechaInicio) {
        this.fechaInicio = fechaInicio;
    }

    public Integer getTipoExpediente() {
        return tipoExpediente;
    }

    public void setTipoExpediente(Integer tipoExpediente) {
        this.tipoExpediente = tipoExpediente;
    }

    public String getNumero() {
        return numero;
    }

    public void setNumero(String numero) {
        this.numero = numero;
    }

    public TipoExpediente getTipoExpedienteId() {
        return tipoExpedienteId;
    }

    public void setTipoExpedienteId(TipoExpediente tipoExpedienteId) {
        this.tipoExpedienteId = tipoExpedienteId;
    }

    public Barrio getBarrioId() {
        return barrioId;
    }

    public void setBarrioId(Barrio barrioId) {
        this.barrioId = barrioId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Expediente)) {
            return false;
        }
        Expediente other = (Expediente) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.base.Expediente[ id=" + id + " ]";
    }
    
}
